home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEleastSquaresModifierTempla < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.8 KB  |  230 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //    Alias|Wavefront Script File
  19. //
  20. //    Creation Date:    June 16, 1997
  21. //    Author:            sw
  22. //
  23. //    Procedure Name:
  24. //    AEleastSquaresModifierTemplate
  25. //
  26. //    Description Name;
  27. //    Creates the attribute editor controls for the leastSquaresModifier node
  28. //
  29. //    Input Value:
  30. //    nodeName
  31. //
  32. //    Output Value:
  33. //    None
  34. //
  35.  
  36. global proc AEleastSquaresModifierTemplate ( string $nodeName )
  37. {
  38.     editorTemplate -beginScrollLayout;
  39.         editorTemplate -beginLayout "Least Squares Modifier Attributes" -collapse 0;
  40.             
  41.             editorTemplate -callCustom
  42.                 "AELSMInputNurbsObjectNew"
  43.                 "AELSMInputNurbsObjectReplace"
  44.                 "attributeCollection";
  45.             editorTemplate -callCustom
  46.                 "AELSMPointConstraintNew"
  47.                 "AELSMPointConstraintReplace"
  48.                 "attributeCollection.pointConstraint";
  49.         editorTemplate -endLayout;        
  50.  
  51.         // suppressed attributes
  52.         editorTemplate -suppress "updatePointModifier";
  53.         editorTemplate -suppress "resetModifier";
  54.         editorTemplate -suppress "objectModifier";
  55.         editorTemplate -suppress "inputCache";
  56.         editorTemplate -suppress "pointSymbolicIndex";
  57.         editorTemplate -suppress "attributeCollection";
  58.  
  59.         // include/call base class/node attributes
  60.         AEabstractBaseCreateTemplate $nodeName;
  61.  
  62.     editorTemplate -addExtraControls;
  63.     editorTemplate -endScrollLayout;
  64. }
  65.  
  66.  
  67. proc AEconnectLSMPointConstraintControls(    string $nodeName,
  68.                                             string $pointConstraint )
  69. {
  70.     // get the index
  71.     //
  72.     string $number[];
  73.     tokenize($pointConstraint,"[]",$number);
  74.     string $index = $number[1];
  75.     if ( $index == "" ) return;
  76.  
  77.     // build the plugName
  78.     //
  79.     string $plugName = $nodeName+".attributeCollection."+$pointConstraint;
  80.  
  81.     // connect the controls
  82.     //
  83.     setParent AELSMPointConstraintLayout;
  84.     frameLayout -e -l $pointConstraint ("AELSMPointConstraintFrame"+$index);
  85.     connectControl ("AELSMPointConstraintU"+$index) -index 2 ($plugName+".pointConstraintUVW.pointConstraintU");
  86.     connectControl ("AELSMPointConstraintWeight"+$index) ($plugName+".pointWeight");
  87.  
  88. }
  89.  
  90.  
  91. proc AEcreateNewLSMPointConstraintControls(    string $nodeName,
  92.                                             string $pointConstraint )
  93. {
  94.     // get the index
  95.     //
  96.     string $number[];
  97.     tokenize($pointConstraint,"[]",$number);
  98.     string $index = $number[1];
  99.     if ( $index == "" ) return;
  100.  
  101.     setUITemplate -pst attributeEditorTemplate;
  102.     frameLayout -cl false -cll false ("AELSMPointConstraintFrame"+$index);
  103.         columnLayout -adj true;
  104.             floatFieldGrp -nf 1 -l "U" ("AELSMPointConstraintU"+$index);
  105.             floatSliderGrp -f true -l "Weight" -min 0.1 -max 1.0 ("AELSMPointConstraintWeight"+$index);
  106.         setParent ..;
  107.     setParent ..;
  108.     AEconnectLSMPointConstraintControls( $nodeName, $pointConstraint );
  109.     setUITemplate -ppt;
  110. }
  111.  
  112.  
  113. global proc AELSMPointConstraintNew ( string $plug )
  114. {
  115.     // get the nodeName
  116.     //
  117.     string $buffer[];
  118.     tokenize($plug,".",$buffer);
  119.     string $nodeName = $buffer[0];
  120.  
  121.     // get all of the elements of the array
  122.     //
  123.     string $tmpPoints[] = `listAttr -m $plug`;
  124.     string $pointConstraints[];
  125.     for ($tmp in $tmpPoints) {
  126.         string $tmpBuffer[];
  127.         tokenize($tmp,".",$tmpBuffer);
  128.         if (size($tmpBuffer) == 1) {
  129.             $pointConstraints[size($pointConstraints)] = $tmp;
  130.         }
  131.     }
  132.     int $numPointConstraints = size($pointConstraints);
  133.  
  134.     setUITemplate -pst attributeEditorTemplate;
  135.     frameLayout -l "Point Constraints" -cl false -cll true;
  136.         columnLayout -adj true AELSMPointConstraintLayout;
  137.             for ( $pointConstraint in $pointConstraints ) {
  138.                 AEcreateNewLSMPointConstraintControls($nodeName, $pointConstraint);
  139.             }
  140.         setParent ..;
  141.     setParent ..;
  142.     setUITemplate -ppt;
  143. }
  144.  
  145.  
  146. global proc AELSMPointConstraintReplace ( string $plug )
  147. {
  148.     // get the nodeName
  149.     //
  150.     string $buffer[];
  151.     tokenize($plug,".",$buffer);
  152.     string $nodeName = $buffer[0];
  153.  
  154.     string $tmpPoints[] = `listAttr -m $plug`;
  155.     string $newPointConstraints[];
  156.     for ($tmp in $tmpPoints) {
  157.         string $tmpBuffer[];
  158.         tokenize($tmp,".",$tmpBuffer);
  159.         if (size($tmpBuffer) == 1) {
  160.             clear $tmpBuffer;
  161.             tokenize($tmp,"[]",$tmpBuffer);
  162.             if ( size($tmpBuffer) > 1 ) {
  163.                 $newPointConstraints[size($newPointConstraints)] = $tmp;
  164.             }
  165.         }
  166.     }
  167.     int $newNumPointConstraints = size($newPointConstraints);
  168.     string $oldPointConstraintLayouts[] = `columnLayout -q -ca AELSMPointConstraintLayout`;
  169.     int $oldNumPointConstraints = size ($oldPointConstraintLayouts);
  170.  
  171.     setParent AELSMPointConstraintLayout;
  172.     columnLayout -e -vis false AELSMPointConstraintLayout;
  173.  
  174.     if ( $newNumPointConstraints >= $oldNumPointConstraints ) {
  175.  
  176.         // replace what we can
  177.         //
  178.         for ( $i = 0; $i < $oldNumPointConstraints; $i++ ) {
  179.             setParent $oldPointConstraintLayouts[$i];
  180.             AEconnectLSMPointConstraintControls($nodeName, $newPointConstraints[$i]);
  181.         }
  182.  
  183.         // and build what we need
  184.         //
  185.         setParent AELSMPointConstraintLayout;
  186.         for ($i = $oldNumPointConstraints; $i < $newNumPointConstraints; $i++) {
  187.             AEcreateNewLSMPointConstraintControls($nodeName, $newPointConstraints[$i]);
  188.         }
  189.  
  190.     } else {
  191.  
  192.         // replace what we need
  193.         //
  194.         for ( $i = 0; $i < $newNumPointConstraints; $i++ ) {
  195.             setParent $oldPointConstraintLayouts[$i];
  196.             AEconnectLSMPointConstraintControls($nodeName, $newPointConstraints[$i]);
  197.         }
  198.  
  199.         // delete old rowLayouts
  200.         //
  201.         setParent AELSMPointConstraintLayout;
  202.         for ($i = $newNumPointConstraints; $i < $oldNumPointConstraints; $i++) {
  203.             deleteUI -layout $oldPointConstraintLayouts[$i];
  204.         }
  205.     }
  206.     columnLayout -e -vis true AELSMPointConstraintLayout;
  207. }
  208.  
  209.  
  210. global proc AELSMInputNurbsObjectNew ( string $plug )
  211. {
  212.     setUITemplate -pst attributeEditorTemplate;
  213.     columnLayout -adj true;
  214.         textFieldGrp -l "Input Nurbs Object" -ed false LSMInputNurbsObject;
  215.     setParent ..;
  216.     AELSMInputNurbsObjectReplace( $plug );
  217.     setUITemplate -ppt;
  218. }
  219.  
  220.  
  221. global proc AELSMInputNurbsObjectReplace ( string $plug )
  222. {
  223.     // get the input nurbs object
  224.     //
  225.     string $inputAttr = ($plug+".inputNurbsObject");
  226.     string $inputNode[] = `listConnections -d false -sh true $inputAttr`;
  227.  
  228.     textFieldGrp -e -tx $inputNode[0] LSMInputNurbsObject;
  229. }
  230.